package Demo04.Demo02;

import java.util.Collections;
import java.util.List;

public class Demo02_Test {
    public static void main(String[] args) {
        Demo02_Manager manager = new Demo02_Manager();
        Demo02_Book book1 = new Demo02_Book(1,"资治通鉴","司马光",200);
        Demo02_Book book2 = new Demo02_Book(2,"史记","司马迁",200);
        Demo02_Book book3 = new Demo02_Book(3,"三国演义","罗贯中",200);
        Demo02_Book book4 = new Demo02_Book(4,"西游记","吴承恩",200);
        Demo02_Book book5 = new Demo02_Book(5,"水浒传","罗贯中",200);
        manager.add(book1);
        manager.add(book2);
        manager.add(book3);
        manager.add(book4);
        manager.add(book5);

        manager.update("红楼梦",250);

        manager.query("4");

        List<Demo02_Book> lgz = manager.queryByAuthor("罗贯中");
        for (Demo02_Book b :lgz){
            System.out.println("查询罗贯中的结果："+b);
        }
        List<Demo02_Book> all = manager.showAll();
        for (Demo02_Book b : all){
            System.out.println(b);
        }
        System.out.println("-------------排序前-------------");
        List<Demo02_Book> book = manager.showAll();
        for (Demo02_Book b : book) {
            System.out.println(b);
        }
        System.out.println("-------------排序后-------------");
        Collections.sort(book);
        for (Demo02_Book b : book) {
            System.out.println(b);
        }
    }
}


